package com.service;

import com.entity.ShopNews;
import com.mapper.ShopNewsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("shopNewsService")
public class ShopNewsServiceImp implements ShopNewsService {

    @Autowired
    private ShopNewsMapper shopNewsMapper;


    @Override
    public int getCountNews() {
        return shopNewsMapper.getCountNews();
    }

    @Override
    public List<ShopNews> getAllNewsByPage(Integer currentPage, Integer pageSize) {
        Integer startPage = (currentPage - 1) * pageSize;
        return shopNewsMapper.selectAllNewsByPage(startPage, pageSize);
    }

    @Override
    public List<ShopNews> getAllNews() {
        return shopNewsMapper.selectAllNews();
    }

    @Override
    public int removeMoreNews(Integer[] ids) {
        return shopNewsMapper.deleteMoreNews(ids);
    }

    @Override
    public int addNews(ShopNews news) {
        return shopNewsMapper.insertSelective(news);
    }

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return shopNewsMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(ShopNews record) {
        return shopNewsMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(ShopNews record) {
        return shopNewsMapper.updateByPrimaryKey(record);
    }
}
